#!/bin/bash

#返回值不为0就退出
set -e

#设置软件源...


#更新系统
sudo apt update && sudo apt upgrade

#创建常用的目录
mkdir -p ~/anaconda3 ~/develop/sources ~/develop/workspace ~/data/installs

#安装必要工具: c++环境, chrome, git, supervisor, shadowsocks, aria2, polipo,subversion
sudo apt install  build-essential pkg-config autopoint gconf-editor \
        chromium-browser git supervisor shadowsocks aria2 polipo subversion

## download config file
svn export https://github.com/imxood/StudyNote/trunk/config ~/data/config

## 配置supervisor服务



## install anaconda3-5.1.0
aria2c https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-5.1.0-Linux-x86_64.sh -d ~/data/installs
bash Anaconda3-5.1.0-Linux-x86_64.sh -b -u -p ~/anaconda3/

## config python environment
echo "export PATH=${HOME}/anaconda3/bin:$PATH" >> ${HOME}/.bashrc
. /home/imxood/.bashrc

if [ ! -f ${HOME}/.pip/pip.conf ]; then
    mkdir -p ${HOME}/.pip
fi

echo \
"[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple" > ${HOME}/.pip/pip.conf

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes

## 安装文本编辑器notepadqq
sudo add-apt-repository ppa:notepadqq-team/notepadqq
sudo apt-get update
sudo apt-get install notepadqq

## 安装vim插件
curl http://j.mp/spf13-vim3 -L -o - | sh

## 安装node， 会自动安装npm
sudo apt install -y nodejs npm

sudo ln -s /usr/bin/nodejs /usr/bin/node

sudo npm install -g cnpm --registry=https://registry.npm.taobao.org

# 升级npm
sudo npm install -g n

sudo n stable

sudo npm install -g yarn
yarn config set registry 'https://registry.npm.taobao.org'

##安装vscode
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" > /etc/apt/sources.list.d/vscode.list'
sudo apt-get update && sudo apt-get install code